home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
pascal
/
schwazz.exe
/
SCHWAZZ.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1992-03-31
|
10KB
|
270 lines
{$A+,B-,D+,E+,F-,G-,I+,L+,N-,O-,R-,S+,V+,X-}
{$M 16384,0,655360}
PROGRAM schwazz;
{ This Program was started as a test for the VGA256.BGI Graphical }
{ device driver in Turbo Pascal 6.0 and can be used as a screen }
{ saving device, or an entertainment demo. }
{ }
{ The BGI file has been incorporated directly into SCHWAZZ.EXE, }
{ so, for the RunTime version, no BGI file is necessary. If }
{ this source file is being compiled, be sure the CONSTANT }
{ PATH_TO_VGA256 contains the full path the the VGA256.BGI }
{ file (including the file name). }
{ }
{ The Device Driver VGA256.BGI was obtained through ShareWare }
{ }
{ This source code is the work of Jonathan D. Duncan and was }
{ completed and Run-Tested on March 20, 1991 using a NorthGate }
{ 386 - 33 Mhz machiene with a Rendition IIe Graphics card and }
{ NEC MultiSync 4D Monitor. }
USES
Crt, { Screen/Keyboard IO-Unit found in Turbo Library }
Graph; { Graphical Unit found in Turbo Library }
CONST { Path to Uses Graphics Driver File }
Path_To_VGA256 = 'C:\CPG\TP\BGI\VGA256.BGI';
VAR
boxes, counter, { Number of Boxes / Counter Variable }
x1, x2, y1, y2, { Top / Bottom X and Y cordinates for boxes }
c1, c2, c3 : INTEGER; { Palette Settings R/G/B }
dirct1, { Change Colors for Inside or Outside }
dirct2 : BOOLEAN; { Decrease or Increase RBG Attribute }
{ -------------------------------------- }
PROCEDURE VGA256DriverProc; EXTERNAL;
{$L vga256.obj}
{ -------------------------------------- }
{ This function checks to insure the presence of VGA hardware }
{$F+} { Far Call Mode }
FUNCTION TestDetect : Integer;
VAR
Gd,Gm : INTEGER; { Driver/Mode for Graphics }
BEGIN { TestDetect }
DetectGraph(Gd,Gm); { Detect hardware }
IF Gd <> VGA THEN
BEGIN { If not Present, Display Message...}
WriteLn('VGA Monitor and Graphics Card Required');
Halt(1) { ...And Halt Program }
END { If/Then }
ELSE
TestDetect := 1; { Otherwise Setup Detect Number }
END; { TestDetect }
{$F-} { End Far Call Mode }
{ -------------------------------------- }
{ Recognize Driver to Graphics Control Unit }
PROCEDURE Install_VGA256;
BEGIN { Install_VGA256 }
IF (InstallUserDriver('VGA256', @TestDetect) = 0) THEN Halt(1);
END; { Install_VGA256 }
{ -------------------------------------- }
{ Incorporate BGI driver into EXE file }
PROCEDURE Register_VGA256;
BEGIN { Register_VGA256 }
IF (RegisterBGIdriver(@VGA256DriverProc) < 0) THEN Halt(1); { Halt if Error }
END; { Register_VGA256 }
{ -------------------------------------- }
{ Initializes Graphics Mode }
PROCEDURE Initialize;
VAR
Gd,Gm : INTEGER; { Driver/Mode Variables for Graphic }
BEGIN { Initialize }
Gd := Detect; { Detect Hardware (Now VGA256) }
InitGraph(Gd, Gm, path_to_vga256); { Initialize Graph Mode }
IF GraphResult <> grOk THEN Halt(1); { Halt Program if Error }
END; { Initialize }
{ -------------------------------------- }
{ Display Text on Graphical Screen Centered Vert. and Horiz. }
PROCEDURE Write_Text;
VAR halfX, quarterY : INTEGER; { Half/Quarter Screen Width/Height }
{---->} procedure Put(level : BYTE; message : STRING);
var width, height : INTEGER; { Starting X/Y pixel }
BEGIN { Put }
width := halfX - (TextWidth(message) DIV 2); { Get X pixel }
height := level * quarterY; { Get Y pixel }
OutTextXY(width, height, message); { Display text message }
{<----} END; { Put }
BEGIN { Write_Text }
SetColor(0); { Set Text Writing Color To Black }
halfX := (GetMaxX DIV 2); { Divide Horiz. Screen in Half }
quarterY := (GetMaxY DIV 4); { Divide Vert. Screen in Quarters }
put(1,'S C H W A Z Z E L 1 . 0') { Write Name Centered }
put(2,'March 31, 1992'); { Write Date Centered }
put(3,'By Jonathan D. Duncan'); { Write Author Centered }
END; { Write_Text }
{ -------------------------------------- }
{ Draws The Rectangles in Different Palette Colors, All appearing Black }
PROCEDURE Draw;
BEGIN { Draw }
x1 := 0; y1 := 0; { Set Top Corner Cordinates }
x2 := GetMaxX; y2 := GetMaxY; { Set Bottom corner Cordinates }
boxes := Random(10) + 20; { Randomly select num boxes (20-30) }
FOR counter := 1 TO 255 DO { Sel All colors to Appear as Black }
SetPalette(counter,0); { For/Do }
FOR counter := 75 TO (75 + boxes) DO { Draw Boxes in Palette colors 75+ }
BEGIN
SetColor(counter); { Select Color for Border }
SetFillStyle(SolidFill, counter); { Select Color for Fill }
BAR(x1, y1, x2, y2); { Draw Bar (Rectangle) }
Inc(x1,(GetMaxX DIV 2) DIV boxes); { Reset Top X cordinate }
x2 := GetMaxX - x1; { Reset Bottom X cordinate }
Inc(y1,(GetMaxY DIV 2) DIV boxes); { Reset Top Y cordinate }
y2 := GetMaxY - y1; { Reset Bottom Y cordinate }
END; { For/Do }
END; { Draw }
{ -------------------------------------- }
{ Switches Physical and Actual Palette Numbers to provide for color change }
PROCEDURE Schwazzel(direction1, direction2 : BOOLEAN; RGB : BYTE);
{---->} procedure RGBlevel; { Change either R, G, or B in RGB }
BEGIN { RGBLevel }
CASE RGB OF { Which Attribute? }
1 : BEGIN
IF direction2 THEN { Increase or Decrease? }
BEGIN
Inc(c1); { Increase | Check for Range Error }
IF (c1 > 2000) THEN c1 := 0;
END { If/Then }
ELSE
BEGIN
Dec(c1); { Decrease | Check for range Error }
IF (c1 < 0) THEN c1 := 2000;
END; { If/Then/Else }
SetRGBPalette(counter, c1, c2, c3); { Change Palette }
END; { Case/1 }
2 : BEGIN
IF direction2 THEN { Increase or Decrease? }
BEGIN
Inc(c2); { Increase | Check for Range Error }
IF (c2 > 2000) THEN c2 := 0;
END { If/Then }
ELSE
BEGIN
Dec(c2); { Decrease | Check for Range Error }
IF (c2 < 0) THEN c2 := 2000;
END; { If/Then/Else }
SetRGBPalette(counter, c1, c2, c3); { Change Palette }
END; { Case/2 }
3 : BEGIN
IF direction2 THEN { Increase or Decrease? }
BEGIN
Inc(c3); { Increase | Check for Range Error }
IF (c3 > 2000) THEN c3 := 0;